import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:fstar/model/course_data2.dart';
import 'package:fstar/page/course_table.dart';
import 'package:fstar/utils/utils.dart';

class CoursePage extends StatefulWidget {
  @override
  State createState() => _CoursePageState();
}

class _CoursePageState extends State<CoursePage>
    with WidgetsBindingObserver, AutomaticKeepAliveClientMixin {
  final _height = 70.0;
  final _weekListScrollController = ScrollController();

  final _pageController = PageController(initialPage: getCurrentWeek());
  final _duration = Duration(milliseconds: 500);
  final _curve = Curves.easeOutQuad;


  List<CourseData2> list =[
    CourseData2(id:'1',name:"sql進階", classroom:"1", week:[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24], row:1, rowSpan:2, teacher:'teacher', defaultColor:Color(0xff33cc99), column:0,top: 1),
    CourseData2(id:'1',name:"sql進階", classroom:"1", week:[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24], row:1, rowSpan:2, teacher:'teacher', defaultColor:Color(0xff33cc99), column:0,top: 2),
    CourseData2(id:'1',name:"sql進階", classroom:"1", week:[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24], row:1, rowSpan:2, teacher:'teacher', defaultColor:Color(0xff33cc99), column:0,top: 3),
    CourseData2(id:'1',name:"sql進階", classroom:"1", week:[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24], row:1, rowSpan:2, teacher:'teacher', defaultColor:Color(0xff33cc99), column:0,top: 3),
    CourseData2(id:'1',name:"sql進階", classroom:"1", week:[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24], row:1, rowSpan:2, teacher:'teacher', defaultColor:Color(0xff33cc99), column:0,top: 3),
   // 3CourseData2(id:'1',name:"sql進階", classroom:"1", week:[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24], row:1, rowSpan:2, teacher:'teacher', defaultColor:Color(0xff33cc99), column:0,top: 3),
  ];

  @override
  void initState() {
    super.initState();
    WidgetsBinding.instance.addObserver(this);
  }
   List <String> times = [
     "8:30 9:15",
    " 9:20 10:05",
     "10:25 11:10",
     "11:15 12:00",
     "13:30 14:15",
     "14:20 15:05",
     "15:25 16:10",
     "16:15 17:00",
     "18:30 19:15",
     "19:20 20:05",
     "8:30 9:15",
     "9:20 10:05",
     "10:25 11:10",
     "11:15 12:00",
     "13:30 14:15",
     "14:20 15:05",
     "15:25 16:10",
     "16:15 17:00",
     "18:30 19:15",
     "19:20 20:05"
   ];
  @override
  void dispose() {
    super.dispose();
    _weekListScrollController.dispose();
    _pageController.dispose();
    WidgetsBinding.instance.removeObserver(this);
  }

  @override
  Widget build(BuildContext context) {
    super.build(context);
    return PageView.builder(
      controller: _pageController,
      itemCount: list.length,
      itemBuilder: (BuildContext context, int index) {
        return Container(
          child: CourseTable(index: index),
        );
      },
    );
  }
  @override
  bool get wantKeepAlive {
    return true;
  }
}
